package com.fujitsu.cn.fnst.dao;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.fujitsu.cn.fnst.entiy.User;
import com.fujitsu.cn.fnst.exception.NotOneException;

@Repository
public class UserDao extends BaseDao<User> {

    public User findUser(String userId) {
        Session session = getSession();
        Criteria criteria = session.createCriteria(User.class).add(
                Restrictions.eq("id", userId));
        User user = null;
        try {
            user = query4One(criteria);
        } catch (NotOneException e) {
        } finally {
            releaseSession(session);
        }
        return user;
    }

}
